package cate.common.table.d;

import cate.common.table.common.ParamSheet;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.List;

@NoteClass(value = "录像馆")
public class GDVideoHall {

    @NoteField(value = "每日最大点赞次数")
    public static int ADMIRE_DAILY;

    @NoteField(value = "点赞奖励")
    public static int ADMIRE_REWARD_NUM;

    @NoteField(value = "单个录像分组里最大录像数量")
    public static int REPLAY_MAX;

    @NoteField(value = "录像快照最多保留天数")
    public static int MAX_KEEP_DAY;

    @NoteField(value = "进入录像馆的战力限制")
    public static int POWER_LIMIT;

    @NoteField(value = "新食灵tids")
    public static List<Integer> NEW_HERO_TIDS;

    @NoteField(value = "个人收藏数量")
    public static int COLLECT_RECORD_NUM;

    @NoteField(value = "个人记录数量")
    public static int MY_RECORD_NUM;

    @NoteClass(value = "录像馆-分组")
    public enum Group {
        /** 我收藏的录像 */
        MY_COLLECT(1),
        /** 热门 */
        POPULAR(2),
        /** 切磋录像 */
        CAI_JI_HU_ZHUO(3),
        /** 积分赛录像 */
        POINT_RACE(4),
        /** 精英赛录像 */
        ELITE_RACE(5),
        /** 天梯 */
        LADDER_RACE(6);


        private int id;
        Group(int id){
            this.id = id;
        }

        public int getId(){
            return this.id;
        }

        public static Group getGroup(int id){
            for(Group group : values()){
                if(group.id == id){
                    return group;
                }
            }
            return null;
        }
    }

    @NoteClass(value = "录像馆-录像存储类型")
    public static class SaveType {

        @NoteField(value = "未知", detail = "优先在本服找 找不到就去跨服找")
        public static final int UNKOWN = 0;

        @NoteField(value = "本服")
        public static final int LOCAL = 1;

        @NoteField(value = "跨服")
        public static final int CROSS = 2;

        @NoteField(value = "专服")
        public static final int GROUP = 3;
    }

    /** 读取excel中配置的参数 */
    public static void initialize(ParamSheet paramSheet) {
        POWER_LIMIT = GDParamTool.getInt(paramSheet, 438,100000);
        ADMIRE_DAILY = GDParamTool.getInt(paramSheet,444, 3);
        ADMIRE_REWARD_NUM = GDParamTool.getInt(paramSheet,445, 3000);
        REPLAY_MAX = GDParamTool.getInt(paramSheet,443, 20);
        String tidStr = GDParamTool.getString(paramSheet, 439, "100700");
        NEW_HERO_TIDS = Str.strArr2intList(tidStr.split("#"));
        COLLECT_RECORD_NUM = GDParamTool.getInt(paramSheet, 440, 20);
        MY_RECORD_NUM = GDParamTool.getInt(paramSheet,442,30);
        MAX_KEEP_DAY = GDParamTool.getInt(paramSheet, 441, 14);
    }

    public static int getReplayMax(int groupId) {
        Group group = Group.getGroup(groupId);
        if(group == null){
            return REPLAY_MAX;
        }
        switch (group){
            case MY_COLLECT:
                return COLLECT_RECORD_NUM;
            default:
                return REPLAY_MAX;
        }
    }

    public static int getRecordKeepDay(int groupId){
        Group group = Group.getGroup(groupId);
        if(group == null){
            return 7;
        }
        switch (group){
            case MY_COLLECT:
            case POPULAR:
            case POINT_RACE:
            case ELITE_RACE:
            case LADDER_RACE:
            case CAI_JI_HU_ZHUO:
                return -1;
            default:
                return 7;
        }
    }
}
